package com.qf.shop.sms.config;

import com.qf.shop.common.constants.RabbitMQCons;
import com.rabbitmq.client.impl.AMQImpl;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
public class RabbitMQConfig {

    @Bean
    public TopicExchange informExchange(){
        return new TopicExchange(RabbitMQCons.INFORM_EXCHANGE,true,false);
    }

    @Bean
    public Queue smsQueue(){
        return new Queue(RabbitMQCons.SMS_QUEUE,true,false,false);
    }

    @Bean
    public Queue emailQueue(){
        return new Queue(RabbitMQCons.EMAIL_QUEUE,true,false,false);
    }

    @Bean
    public Binding bindSmsQueue(){
        return BindingBuilder.bind(smsQueue()).to(informExchange()).with(RabbitMQCons.SMS_RULE);
    }

    @Bean
    public Binding bindEmailQueue(){
        return BindingBuilder.bind(emailQueue()).to(informExchange()).with(RabbitMQCons.EMAIL_RULE);
    }


}
